<div class="menu_top">
	<input type="hidden" name="action" value="editor_shipping" />
    <input type="hidden" name="shipping" value="<?php echo $_REQUEST['shipping']; ?>" />
	<img title="<?php echo ucfirst($txt->getWord('save')); ?>" class="icon command" src="<?php echo SYSICONS_URL; ?>filesave_22.gif" onclick="edit_form.submit();"  />  
    <a href="?con=<?php echo $_REQUEST['con']; ?>&shipping=<?php echo $_REQUEST['shipping']; ?>&amp;edit=rules"><img title="<?php echo ucfirst($txt->getWord('rules')); ?>" class="icon command" src="<?php echo SYSICONS_URL; ?>rules_22.gif" /></a>
</div>
<?php $countries = getCountryList(); ?>
<div class="menu_list">
<table id="menulist" class="item_list" cellspacing="0" cellpadding="0" border="0">
	<thead class="fields">
        <tr>
            <th class="first center">&nbsp;&nbsp;#&nbsp;&nbsp;</th>
            <th><?php echo ucfirst($txt->getWord('zone')); ?></th>
            <th><?php echo ucfirst($txt->getWord('country')); ?></th>
            <th><?php echo ucfirst($txt->getWord('email')); ?></th>
            <th><?php echo ucfirst($txt->getWord('code')); ?></th>
            <th><?php echo ucfirst($txt->getWord('city')); ?></th>
            <th><?php echo ucfirst($txt->getWord('zip_start')); ?></th>
            <th><?php echo ucfirst($txt->getWord('zip_end')); ?></th>
            <th><?php echo ucfirst($txt->getWord('new')); ?></th>
            <th><?php echo ucfirst($txt->getWord('edit')); ?></th>
            <th class="last"><?php echo ucfirst($txt->getWord('delete')); ?></th>
        </tr>
    </thead>
    <tbody>
        <tr class="items">
            <td class="first center">0</td>
            <td><input class="small" id="new_zone" name="new_zone[]" type="text" value="" maxlength="50" /></td>
            <td>
                <select class="small" name="new_zone_country[]" >
                    <option value="0" <?php echo getIsSelectedHTML($zone['country'], ''); ?>><?php echo ucfirst($txt->getWord('undefined')); ?></option>
                    <?php 
                    if($countries)
                    {
                        foreach($countries as $country)
                        { echo '<option value="'.$country['iso'].'" '.getIsSelectedHTML($country['iso'], $zone['country']).'>'.$country['printable_name'].'</option>'; }
                    }
                    ?>
                </select>
            </td>
            <td colspan="5">&nbsp;</td>
            <td class="center">
            	<img 
                	title="<?php echo ucfirst($txt->getWord('new_zone')); ?>"
                    class="icon command" 
                    src="<?php echo SYSICONS_URL; ?>add_16.gif" 
                    onclick="if(document.getElementById('new_zone').value != '') { edit_form.submit(); }" />
            </td>
            <td colspan="2" class="last">&nbsp;</td>
        </tr>
        <?php 
        if($zones):
		
        foreach($zones as $zone)
        {
			?>
			<tr class="items">
				<td class="first center"><?php echo $zone['id']; ?><input type="hidden" name="zone_id[]" value="<?php echo $zone['id']; ?>" /></td>
				<td> 
					<input class="small" name="zone_title[]" type="text" value="<?php echo $zone['title']; ?>" maxlength="50" />
				</td>
				<td>
					<select class="small" name="zone_country[]" >
						<option value="0" <?php echo getIsSelectedHTML($zone['country'], ''); ?>><?php echo ucfirst($txt->getWord('undefined')); ?></option>
                        <?php 
						if($countries)
						{
							foreach($countries as $country)
							{ echo '<option value="'.$country['iso'].'" '.getIsSelectedHTML($country['iso'], $zone['country']).'>'.$country['printable_name'].'</option>'; }
						}
						?>
					</select>
				</td>
                <td> 
					<input class="small" name="zone_email[]" type="text" value="<?php echo $zone['email']; ?>" maxlength="100" />
				</td>
                <td> 
					<input class="small" name="zone_code[]" type="text" value="<?php echo $zone['code']; ?>" maxlength="50" />
				</td>
                <td><input class="small" name="new_city[]" type="text" value="" maxlength="50" /></td>
                <td><input id="new_zip_start_<?php echo $zone['id']; ?>" class="small" name="new_zip_start[]" type="text" value="0" maxlength="9" /></td>
                <td><input id="new_zip_end_<?php echo $zone['id']; ?>" class="small" name="new_zip_end[]" type="text" value="0" maxlength="9" />
                </td>
                <td class="center">
					<img title="<?php echo ucfirst($txt->getWord('new_area')); ?>" class="icon command" src="<?php echo SYSICONS_URL; ?>area_new_16.gif" 
                    onclick="if((document.getElementById('new_zip_start_<?php echo $zone['id']; ?>').value > 0) || (document.getElementById('new_zip_end_<?php echo $zone['id']; ?>').value > 0)) { edit_form.submit(); }" />
				</td>
				<td class="center">
					<a href="?con=<?php echo $_REQUEST['con']; ?>&shipping=<?php echo $zone['parent_id']; ?>&amp;edit=rules&amp;zone=<?php echo $zone['id']; ?>"><img title="<?php echo ucfirst($txt->getWord('edit')); ?>" class="icon command" src="<?php echo SYSICONS_URL; ?>configure_16.gif" onclick="edit_form.submit();"  /></a>
				</td>
				<td class="last center">
					<input title="<?php echo ucfirst($txt->getWord('delete')); ?>" class="inp_image" type="image" name="delete_zone" src="<?php echo SYSICONS_URL; ?>delete_16.gif" value="0" onclick="this.value='<?php echo $zone['id']; ?>'; edit_form.submit();" />
				</td>
			</tr>
            <?php if($areas[$zone['id']])
			{ 
				foreach($areas[$zone['id']] as $area)
				{
					?>
                    <tr class="items">
                        <td class="first" colspan="5"><input type="hidden" name="area_id[]" value="<?php echo $area['id']; ?>" /></td>
                        <td><input class="small" name="area_city[]" type="text" value="<?php echo $area['city']; ?>" maxlength="50" /></td>
                        <td><input class="small" name="area_zip_start[]" type="text" value="<?php echo $area['zip_start']; ?>" maxlength="9" /></td>
                        <td><input class="small" name="area_zip_end[]" type="text" value="<?php echo $area['zip_end']; ?>" maxlength="9" /></td>
                        <td>&nbsp;</td>
                        <td class="center"><img title="<?php echo ucfirst($txt->getWord('apply')); ?>" class="icon command" src="<?php echo SYSICONS_URL; ?>ok_16.gif" onclick="edit_form.submit();"  /></td>
                        <td class="last center">
					<input title="<?php echo ucfirst($txt->getWord('delete').' '.$txt->getWord('area')); ?>" class="inp_image" type="image" name="delete_area" src="<?php echo SYSICONS_URL; ?>remove_16.gif" value="0" onclick="this.value='<?php echo $area['id']; ?>'; edit_form.submit();" />
						</td>
                    </tr>
            <?php 
				}
			}
        }
        endif; 
        ?>
	</tbody>
</table>
</div>